package com.cy.sys.controller;


import com.cy.sys.common.pojo.JsonResult;
import com.cy.sys.service.AdminService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RequestMapping("/admin/")
@RestController
@CrossOrigin
public class AdminController {
    @Autowired
    private AdminService adminService;
    @GetMapping("login/{username}/{password}")
    @ApiOperation(value = "登录", notes = "接收username,password，进行登录")
    public JsonResult doLogin(@PathVariable String username,
                              @PathVariable String password){
        adminService.login(username,password);
        return new JsonResult(1,"登陆ok");
    }
    @PostMapping("register/{username}/{password}")
    @ApiOperation(notes = "接收username,password,id不用输入", value = "注册", httpMethod = "POST")
    public JsonResult doRegister(@PathVariable String username,
                                 @PathVariable String password){
        adminService.register(username,password);
        return new JsonResult(1,"注册ok");
    }

}
